import numpy as np
import mindspore as ms
import mindspore.nn as nn
from mindspore.ops import functional as F
from mindspore.common.initializer import initializer


class TestNet(nn.Cell):
    def __init__(self):
        super(TestNet, self).__init__()
        self.op = nn.Conv1d(120, 240, 4, has_bias=True, weight_init='ones')

    def construct(self, x):
        out = self.op(x)
        return [out]


if __name__ == "__main__":
    net = TestNet()
    # weight_shape = encoder.fc.weight.shape
    # weight = initializer('ones', shape=weight_shape, dtype=ms.float32)
    # encoder.fc.weight = weight
    x = np.ones([1, 120, 640]).astype(np.float32)
    x = ms.Tensor(x, ms.float32)
    print(x)
    result = net(x)
    print(result[0])
    print(result[0].mean())
    print(result[0].shape)
